package com.loop.inClass;

import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.TreeSet;

public class StudentDemo {
    public static void main(String[] args) {
        TreeSet<Student> set = new TreeSet<>(
                new Comparator<Student>() {
                    @Override
                    public int compare(Student o1, Student o2) {
                        return o1.getAge()-o2.getAge() == 0 ? o1.getName().compareTo(o2.getName()) : o1.getAge()-o2.getAge();
                    }
                }
        );
        set.add(new Student("该刘子",14));
        set.add(new Student("刘能",33));
        set.add(new Student("三七",18));
        set.add(new Student("该刘子",14));
        System.out.println(set);
        linkedHashSetDemo();
    }


    public static void linkedHashSetDemo(){
        LinkedHashSet<Integer> linkedHashSet = new LinkedHashSet<>();
        linkedHashSet.add(12);
        linkedHashSet.add(13);
        linkedHashSet.add(15);
        linkedHashSet.add(10);
        HashSet<Integer> set = new HashSet<>();
        set.add(12);
        set.add(13);
        set.add(15);
        set.add(10);
        System.out.println(linkedHashSet);
        System.out.println(set);
    }
}
